﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;

namespace Rarous.TexyNet.Web.UI
{
    /// <summary>
    /// Ovládací prvek pro převod texu v Texy syntaxu do XHTML.
    /// </summary>
    [ParseChildren(true, "Texy")]
    [PersistChildren(false)]
    [ToolboxData("<{0}:Texyfy runat=\"server\"></{0}:Texyfy>")]
    public class Texyfy : Control
    {
        private string texy;

        /// <summary>
        /// Vraci text prevedeny na XHTML
        /// </summary>
        public string Text
        {
            get { return Rarous.TexyNet.Texy.Process(texy); }
        }

        /// <summary>
        /// Vraci nebo nastavuje
        /// </summary>
        [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
        public string Texy
        {
            get { return texy; }
            set { texy = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(Text);
        }
    }
}
